<template>
  <div class="nav-header">
    <div class="menu-fold" @click="foldClick">
      <el-icon :size="25">
        <component :is="isFold"></component>
      </el-icon>
    </div>
    <div class="headerContent">
      <div class="breadcrumb">
        <bread-crumb :breadItemData="breadPath"></bread-crumb>
      </div>
      <div class="userInfo">
        <user-info></user-info>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, defineEmits, reactive } from 'vue';
import { breadCrumb } from '@/base-ui/breadCrumb';
import { userInfo } from '../index';
/* 折叠菜单 */
const isFold = ref('fold');
const emits = defineEmits(['listenFold']);
const foldClick = () => {
  if (isFold.value === 'expand') {
    isFold.value = 'fold';
  } else {
    isFold.value = 'expand';
  }
  emits('listenFold', {
    isFold: isFold.value == 'fold' ? true : false
  });
};
/* 面包屑 */
import { useStore } from '@/store';
import { useRoute } from 'vue-router';
import { breadCrumbPath } from '@/utils/mapMenus';
import { computed } from 'vue';
const store = useStore();
const breadPath = computed(() => {
  const usermenus = store.state.login.userMenus;
  const route = useRoute();
  return breadCrumbPath(usermenus, route.path);
});
</script>

<style scoped lang="less">
.nav-header {
  // background-color: pink;
  height: 100%;
  display: flex;
  .menu-fold {
    width: 30px;
    height: 100%;
    padding-left: 10px;
    // background-color: blue;
    .el-icon {
      margin-top: 7px;
    }
  }
  .headerContent {
    flex: 1;
    align-items: center;
    display: flex;
    justify-content: space-between;
    // background-color: skyblue;
    .userInfo {
      margin-right: 40px;
    }
  }
}
</style>
